<?php
if(cmd('lines')){
  $lineCount=0;
  $otherCount=0;
  $moduleCount=0;
  $controlCount=0;
  $disabledCount=0;
  foreach(dirlist('./',true) as $file){
    if(substr($file,strlen($file)-4)=='.php'){
      $lineCount+=count(file($file));
      $otherCount++;
    }
  }
  foreach(dirlist('./modules/',true) as $file){
    if(substr($file,strlen($file)-4)=='.php'){
      if(substr($file,10,1)!='_'){
        $lineCount+=count(file($file));
      } else {
        $disabledCount++;
      }
      $moduleCount++;
    }
  }
  foreach(dirlist('./controls/',true) as $file){
    if(substr($file,strlen($file)-4)=='.php'){
      $lineCount+=count(file($file));
      $controlCount++;
    }
  }
  reply("Lines of PHP code used for $nickname: $lineCount [$moduleCount modules ($disabledCount disabled), $controlCount controls, and $otherCount other]");
}
if(cmd('modules')){
  $moduleList = '';
  $moduleListDis = '';
  foreach(dirlist('./modules') as $file){
    if($file!='..' and substr($file,0,7)!='BACKUP_' and substr($file,0,8)!='_BACKUP_'){
    	$lines = count(file('./modules/' . $file));
    	if(substr($file,strlen($file)-4)!='.php'){
    	} else if(substr($file,0,1)=='_'){
	    	if(substr($file,0,3)=='_z_'){
	        $moduleListDis.=', '.substr($file,3,strlen($file)-7) . " (LastLoad, $lines)";
	      } else {
        	$moduleListDis.=', '.substr($file,1,strlen($file)-5) . " ($lines)";
        }
      } else if(substr($file,0,2)=='z_'){
        $moduleList.=', '.substr($file,2,strlen($file)-6) . " (LastLoad, $lines)";
      } else {
        $moduleList.=', '.substr($file,0,strlen($file)-4) . " ($lines)";
      }
    }
  }
  reply('Current modules (line count in parathesis): ' . trim($moduleList, ', ') . ((strlen($moduleListDis) > 0) ? (' (Disabled: ' . trim($moduleListDis, ', ') . ')') : ''));
}
?>